{% from 'macros.html' import nav_link %}
<!DOCTYPE html>
<html lang="en">
<head>
    {% block head %}
        <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css">
        <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">

    <title>{% block title %}{% endblock %}-KKlog</title>
    <link rel="icon" href="{{ url_for('static',filename='favicon.ico') }}">
        <link rel="stylesheet" href="{{ url_for('static',filename='css/style.css') }}" type="text/css">

    {% endblock %}
</head>
<body>
{% block nav %}
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">


    <a class="navbar-brand" href="/">KKlog</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarColor01">
        <ul class="navbar-nav mr-auto">
            {{ nav_link('blog.index','首页') }}
            {{ nav_link('blog.about','关于') }}
        </ul>
        <form class="form-inline my-2 my-lg-0" action="{{ url_for('blog.search') }}">
            <input class="form-control mr-sm-2" type="search" placeholder="搜索文章、标题" aria-label="Search" name="q">
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜索</button>
        </form>


        <ul class="nav navbar-nav navbar-right">
    {% if current_user.is_authenticated %}


    <li class="nav-item dropdown">
    <a href="{{ url_for('admin.new') }}" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" id="navbarDropdown"> 发布 <span class="caret"></span></a>
    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
        <a href="{{ url_for('admin.new_post') }}" class="dropdown-item">文章</a>
        <a href="{{ url_for('admin.new_category') }}" class="dropdown-item">分类</a>
    </div>
    </li>
    <li class="nav-item dropdown">
        <a href="{{ url_for('admin.manage') }}" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" id="navbarDropdown"> 管理 <span class="caret"></span>
            {% if unread_comments %}
            <span class="badge badge-success">new</span>
            {% endif %}
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
            <a href="{{ url_for('admin.manage_post') }}" class="dropdown-item">文章</a>
            <a href="{{ url_for('admin.manage_category') }}" class="dropdown-item">分类</a>
            <a href="{{ url_for('admin.manage_comment') }}" class="dropdown-item">评论
            {% if unread_comments %}
                <span class="badge badge-success">{{ unread_comments }}</span>
                {% endif %}
            </a>

        </div>

    </li>


{#    {{ render_nav_item('admin.settings','Settings') }}#}
    {% endif %}

</ul>
    </div>
</div>
</nav>

{% endblock %}




<main class="container">
    <br>
    {% for message in get_flashed_messages(with_categories=True) %}
    <div class="alert alert-{{ message[0] }}" role="alert">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        {{ message[1] }}
    </div>
    {% endfor %}
    {% block content %} {% endblock %}

</main>

{% block scripts %}

{{ moment.include_moment(local_js=url_for('static',filename='js/moment-with-locales.min.js')) }}
{{ moment.locale(auto_detect=True) }}
 <script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
{% endblock %}
<br>
<hr>
    {% block footer %}
<center>
<footer >
            <small> &copy; 2018 <a href="http://www.baidu.com" title="Written by KK">KK</a> /
            <a href="https://github.com/PythonerKK" title="Fork me on GitHub">GitHub</a> /
            all right reserved.

                {% if current_user.is_authenticated %}
                <a href="{{ url_for('auth.logout',next=request.full_path) }}">Logout</a>
                {% else %}
                <a href="{{ url_for('auth.login',next=request.full_path) }}">Login</a>
                {% endif %}
        </small>
</footer>
    </center>
    {% endblock %}
</body>
</html>